<?php
namespace app\course\validate\payment;

use think\Validate;

/**
 * 支付订单验证
 */
class PaymentOrder extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'course_id'     => 'require|integer',
        'course_ids'    => [
            'require',
            'regex' => '^[,\d]+$',
        ],
        // 'promotion_id'  => 'requireWithout:|integer',
        // 'coupon_id'     => 'require|integer',
        'price'         => 'require|float',
        'section_id'    => 'require|integer',
        'price'         => 'require|float',
        'course'        => 'require',
        'mhm_id'        => 'require|integer',
        // 'from'          => 'require|in:android,ios,pc,miniprogram,h5',
    ];

    protected $field = [
        'course_id'     => '课程',
        'course_ids'    => '课程',
        'section_id'    => '课时',
        'price'         => '价格',
        'course'        => '课程参数',
        'mhm_id'        => '机构',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'course_fetch'      => ['course_id'],
        'course_credit'     => ['course_id'],
        // 'course_credit'     => ['course_id', 'promotion_id', 'coupon_id'],
        'course_order'      => ['course_id'],
        'section'           => ['section_id'],
        'order_cart'        => ['course_ids'],
        'order_cart_create' => ['course'],
        'cart_add'          => ['course_id'],
        
    ];

}
